﻿using System;
using System.IO;
using Android.App;
using Android.Content;
using Android.Runtime;
using Android.Views;
using Android.Widget;
using Android.OS;
using Environment = System.Environment;
using Android.Util;

namespace DbFileTest
{
    [Activity(Label = "DbFileTest", MainLauncher = true, Icon = "@drawable/icon")]
    public class Activity1 : Activity
    {
        int count = 1;

        protected override void OnCreate(Bundle bundle)
        {
            base.OnCreate(bundle);

            // Set our view from the "main" layout resource
           // SetContentView(Resource.Layout.Main);

            // Get our button from the layout resource,
            // and attach an event to it
          //  Button button = FindViewById<Button>(Resource.Id.MyButton);

          //  button.Click += delegate { button.Text = string.Format("{0} clicks!", count++); };

            LinearLayout layout=new LinearLayout(this);

            layout.Orientation=Orientation.Vertical;
            SetContentView(layout);
            
           // layout.AddView(new TextView(this){Text = });

            var appLocalData = Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData);
            var appData = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData);
            var per=Environment.GetFolderPath(Environment.SpecialFolder.Personal);
            var commAppData=Environment.GetFolderPath(Environment.SpecialFolder.CommonApplicationData);

          //  var db = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.Personal), "./../database/");

            DirectoryInfo di = Directory.GetParent(per);

            var dbhelp = new dbhelper(this, "demodb");
            var writeableDb = dbhelp.WritableDatabase;
            writeableDb.Close();
            dbhelp.Close();
            
            
            var db = Path.Combine(di.FullName,"databases");//Path.Combine(di.Parent.f, "/database/");
            if (new DirectoryInfo(db).Exists)
            {
                Log.Debug("Activity1:", "Database directory exist.");
            }
            layout.AddView(new TextView(this){Text ="applocaldata:"+appLocalData });
            layout.AddView(new TextView(this) { Text = "appData:" + appData });
            layout.AddView(new TextView(this) { Text = "per:" + per });
            layout.AddView(new TextView(this) { Text = "commAppData:" + commAppData });
            layout.AddView(new TextView(this) { Text = "db:" + db });

        }
    }
}

